package com.ce.webframework.sec.service.impl;

import java.util.List;

import com.ce.webframework.sec.model.SecDragSourceDO;
import com.ce.webframework.sec.model.SecDragSourceTempDO;
import com.ce.webframework.sec.service.ISecDragSourceTempService;
import com.ce.webframework.sec.dao.ISecDragSourceDao;
import com.ce.webframework.sec.dao.ISecDragSourceTempDao;
import com.sitechasia.webx.core.service.impl.BaseService;

/**
 * 拖动源manager
 *
 */
public class SecDragSourceServiceTempImpl extends BaseService implements ISecDragSourceTempService {

	private ISecDragSourceTempDao secDragSourceTempDao;
	private ISecDragSourceDao secDragSourceDao;



	/**
	 * 设置拖动源模板dao
	 * @param secDragSourceTempDao 拖动源模板dao
	 */
	public void setSecDragSourceTempDao(ISecDragSourceTempDao secDragSourceTempDao) {
		this.secDragSourceTempDao = secDragSourceTempDao;
	}

	/**
	 * 设置拖动源dao
	 * @param secDragSourceDao 拖动源模板dao
	 */
	public void setSecDragSourceDao(ISecDragSourceDao secDragSourceDao) {
		this.secDragSourceDao = secDragSourceDao;
	}

	/**
	 * 功能描述:返回当前用户未使用的模块
	 * @param userId  用户标识
	 * @param type  类型
	 * @param epId  企业标识
	 * @param functionEntityIds  企业标识
	 * @return SecDragSourceTempDO 集合
	 */
	public List<SecDragSourceTempDO> getUnuserModels(Long userId, String type
			, Long epId, List<String> functionEntityIds){

		List<SecDragSourceTempDO> allTemps = secDragSourceTempDao.
			getDragSourceTemps(userId, type, epId, functionEntityIds);

		List<SecDragSourceDO> allds =
			secDragSourceDao.getDragSources(userId, functionEntityIds, epId);

		if (allds != null && allds.size() > 0){
			for(SecDragSourceDO sds:allds){
				for(SecDragSourceTempDO sdst:allTemps){
					if(sdst.getDragSourceTempId()
							.equals(sds.getSecDragSourceTempDO()
							.getDragSourceTempId())){
						allTemps.remove(sdst);
						break;
					}
				}
			}
		}

		return allTemps;
	}
}
